import java.io.*;

public class test {

    public static void main(String[] args) {
        String filePath = "C:/Users/Administrator/Desktop/HZ/";
        String command = "ffmpeg -re -i " + filePath + "test.mp4 -vcodec copy -acodec copy -f  flv -y rtmp://121.4.36.249/13/fileName";
        //线程开启, 不会打开外部cmd
//        String command = "cmd /k  ffmpeg -re -i " + filePath + "test.flv -vcodec copy -acodec copy -f  flv -y rtmp://121.4.36.249/folder4/fileName";
        StringBuilder sb = new StringBuilder();
        try {
            String[] windows = {"cmd", "/C", "start " + command};    //弹框推流
            String[] windows2 = {"cmd", "/k", command};              //不弹框推流
            String[] linux = {"/bin/sh", "-c", "ln -s exe1 exe2"};
            String[] linux2 = {"/bin/sh", "-c", "xterm -e ln -s exe1 exe2"};

            Thread t = new Thread(new Runnable() {
                public void run() {
                    try {
                        Process process = Runtime.getRuntime().exec(windows2);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            });
            t.start();

           /*
            System.out.println("Process exitValue: " + process.waitFor());
            //取得命令结果的输出流
            InputStream fis = process.getInputStream();
            //用一个读输出流类去读
            InputStreamReader isr = new InputStreamReader(fis);
            //用缓冲器读行
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            //直到读完为止
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
            System.out.println(sb.toString());*/
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
